package org.other.test1720;

public class Solution {

    public static void main(String[] args) {

        int[] arr={6,2,7,3};
        int first=4;

        for (int i:decode(arr,first)){
            System.out.print(i);
        }

    }

    public static int[] decode(int[] encoded, int first) {

        int[] result=new int[encoded.length+1];

        result[0]=first;

        for (int i=1;i<result.length;i++){
            result[i]=encoded[i-1]^result[i-1];
        }

        return result;

    }

}
